<?php

namespace app\common\model;

/**
 * 用户等级
 * Class Grade
 * @package app\admin\model
 */
class Grade extends BaseModel
{
    protected $name = 'member_grade';

    protected $pk = 'member_grade_id';
    /**
     * 追加字段
     * @var array
     */
    protected $append = [
        
    ];

    /**
     * 隐藏字段
     * @var array
     */
    protected $hidden = [

    ];

    /**
     * 关联会员图
     * @return \think\model\relation\HasOne
     */
    public function image()
    {
        return $this->hasOne("app\\common\\model\\UploadFile", 'file_id', 'image_id');
    }

    // 会员等级列表
    public function getList($grade_status = 1,$is_delete = 0,$order = ['weight' => 'asc']){
        $where = [
            'grade_status' => $grade_status,
            'is_delete' => $is_delete
        ];
        return $this->where($where)
        ->with(["image"])
        ->order($order)
        ->field("grade_id,grade_name,upgrade,discount,image_id,weight,describes,grade_status,create_time")
        ->paginate(15, false, [
            'query' => request()->request()
        ]);
    }
}